//查询表的路由


const {objMod} = require('../models');


let res = {
  //查询Users表
  "/selectUser": ["get", async (ctx, next) => {

    let articles = await objMod.Users.findAll({
      attributes: ["id","username", "password"]
    });
    ctx.body = articles;

    console.log(articles);
     
    console.log("articles的类型" + typeof (articles));

  }],
   //查询Message表
   "/selectMessage": ["get", async (ctx, next) => {

    let articles = await objMod.Message.findAll({
      attributes: ["id", "fromUserId", "content"]
    });

    ctx.body = articles;
    console.log(articles);
     
    console.log("articles的类型" + typeof (articles));

  }],
  //查询Message表
  "/selectComment": ["get", async (ctx, next) => {

    let articles = await objMod.Comment.findAll({
      // attributes: ["id", "fromUserId", "content"]
    });

    ctx.body = articles;
    console.log(articles);
     
    console.log("articles的类型" + typeof (articles));
  }],

   //查询likes表
   "/selectLike": ["get", async (ctx, next) => {

    let articles = await objMod.Like.findAll({
      attributes: ["id", "userId", "msgId", "applaud"],
  });
    ctx.body = articles;
    console.log(articles);

    console.log("articles的类型" + typeof (articles));
  }],
 
}

module.exports = res;